repo: Allow using options for fetching summary
authorKrzesimir Nowak <krzesimir@kinvolk.io>
Tue, 10 May 2016 10:45:49 +0000 (12:45 +0200)
committerColin Walters (automation) <walters+githubbot@verbum.org>
Tue, 10 May 2016 13:47:36 +0000 (13:47 +0000)
This adds a _with_options variant of the
ostree_repo_remote_fetch_summary function, so we can tell the fetcher
to use a specific URL instead taking it from the remote config.

Closes: #290
Approved by: cgwalters

apidoc/ostree-sections.txt
src/libostree/libostree.sym
src/libostree/ostree-repo.c
src/libostree/ostree-repo.h

index 3b185ac0fd1566a66816f2ca92e0ec2822c49ee5..b9b292c7fbe180474e84c77bac0ac30f988ec2c7 100644 (file)
@@ -246,6 +246,7 @@ ostree_repo_remote_get_gpg_verify
 ostree_repo_remote_get_gpg_verify_summary
 ostree_repo_remote_gpg_import
 ostree_repo_remote_fetch_summary
+ostree_repo_remote_fetch_summary_with_options
 ostree_repo_get_remote_boolean_option
 ostree_repo_get_remote_list_option
 ostree_repo_get_remote_option
index 8c0d8389d916819ee4858263035a6e2eeb4336bd..2aa72512785492e9a8c4000b27985d2c49484b13 100644 (file)
@@ -337,3 +337,9 @@ global:
  * Versions above here are released.  Only add symbols below this line.
  *                         NOTE NOTE NOTE
  */
+
+LIBOSTREE_2016.6 {
+global:
+        ostree_repo_remote_fetch_summary_with_options;
+
+} LIBOSTREE_2016.5;
index 243b7ae665ec5d7ddc04ad6610b44f2e4e1397e0..42813e9c322aa524697c9730e3a90f3d9f663ee8 100644 (file)
@@ -1895,6 +1895,7 @@ static gboolean
 repo_remote_fetch_summary (OstreeRepo    *self,
                            const char    *name,
                            const char    *metalink_url_string,
+                           GVariant      *options,
                            GBytes       **out_summary,
                            GBytes       **out_signatures,
                            GCancellable  *cancellable,
@@ -1905,6 +1906,10 @@ repo_remote_fetch_summary (OstreeRepo    *self,
   gboolean ret = FALSE;
   SoupURI *base_uri = NULL;
   gboolean from_cache = FALSE;
+  g_autofree char *url_override = NULL;
+
+  if (options)
+    (void) g_variant_lookup (options, "override-url", "&s", &url_override);
 
   mainctx = g_main_context_new ();
   g_main_context_push_thread_default (mainctx);
@@ -1917,11 +1922,10 @@ repo_remote_fetch_summary (OstreeRepo    *self,
     g_autofree char *url_string = NULL;
     if (metalink_url_string)
       url_string = g_strdup (metalink_url_string);
-    else
-      {
-        if (!ostree_repo_remote_get_url (self, name, &url_string, error))
-          goto out;
-      }
+    else if (url_override)
+      url_string = g_strdup (url_override);
+    else if (!ostree_repo_remote_get_url (self, name, &url_string, error))
+      goto out;
 
     base_uri = soup_uri_new (url_string);
     if (base_uri == NULL)
@@ -2004,8 +2008,8 @@ repo_remote_fetch_summary (OstreeRepo    *self,
  * ostree_repo_remote_fetch_summary:
  * @self: Self
  * @name: name of a remote
- * @out_summary: (allow-none): return location for raw summary data, or %NULL
- * @out_signatures: (allow-none): return location for raw summary signature
+ * @out_summary: (nullable): return location for raw summary data, or %NULL
+ * @out_signatures: (nullable): return location for raw summary signature
  *                                data, or %NULL
  * @cancellable: a #GCancellable
  * @error: a #GError
@@ -2030,6 +2034,42 @@ ostree_repo_remote_fetch_summary (OstreeRepo    *self,
                                   GBytes       **out_signatures,
                                   GCancellable  *cancellable,
                                   GError       **error)
+{
+  return ostree_repo_remote_fetch_summary_with_options (self,
+                                                        name,
+                                                        NULL,
+                                                        out_summary,
+                                                        out_signatures,
+                                                        cancellable,
+                                                        error);
+}
+
+/**
+ * ostree_repo_remote_fetch_summary_with_options:
+ * @self: Self
+ * @name: name of a remote
+ * @options: (nullable): A GVariant a{sv} with an extensible set of flags
+ * @out_summary: (nullable): return location for raw summary data, or %NULL
+ * @out_signatures: (nullable): return location for raw summary signature
+ *                              data, or %NULL
+ * @cancellable: a #GCancellable
+ * @error: a #GError
+ *
+ * Like ostree_repo_remote_fetch_summary(), but supports an extensible set of flags.
+ * The following are currently defined:
+ *
+ * - override-url (s): Fetch summary from this URL if remote specifies no metalink in options
+ *
+ * Returns: %TRUE on success, %FALSE on failure
+ */
+gboolean
+ostree_repo_remote_fetch_summary_with_options (OstreeRepo    *self,
+                                               const char    *name,
+                                               GVariant      *options,
+                                               GBytes       **out_summary,
+                                               GBytes       **out_signatures,
+                                               GCancellable  *cancellable,
+                                               GError       **error)
 {
 #ifdef HAVE_LIBSOUP
   g_autofree char *metalink_url_string = NULL;
@@ -2048,6 +2088,7 @@ ostree_repo_remote_fetch_summary (OstreeRepo    *self,
   if (!repo_remote_fetch_summary (self,
                                   name,
                                   metalink_url_string,
+                                  options,
                                   &summary,
                                   &signatures,
                                   cancellable,
index d9c61ebc1ef832926e42568d8bd7e6b060e506d0..f0fa53a3b75f77aaedbb343bb11729dee8103e03 100644 (file)
@@ -194,6 +194,15 @@ gboolean      ostree_repo_remote_fetch_summary (OstreeRepo    *self,
                                                 GCancellable  *cancellable,
                                                 GError       **error);
 
+_OSTREE_PUBLIC
+gboolean ostree_repo_remote_fetch_summary_with_options (OstreeRepo    *self,
+                                                        const char    *name,
+                                                        GVariant      *options,
+                                                        GBytes       **out_summary,
+                                                        GBytes       **out_signatures,
+                                                        GCancellable  *cancellable,
+                                                        GError       **error);
+
 _OSTREE_PUBLIC
 OstreeRepo * ostree_repo_get_parent (OstreeRepo  *self);